#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
int compar(const void* x, const void* y)
{
	return (*(int*)x - *(int*)y);
}
int main()
{
	int m = 0, n = 0;
	int arr[2000000];
	int tmp = 0;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++)
	{
		scanf("%d", &tmp);
		if (tmp <= n && tmp >= 0)
			arr[i] = tmp;
	}
	qsort(arr, m, sizeof(arr[0]), compar);
	for (int i = 0; i < m; i++)
	{
		printf("%d ", arr[i]);
	}
	return 0;
}
